<?php

namespace App\Http\Resources\goods;

use App\Models\goods\GoodsCate;
use Illuminate\Http\Resources\Json\ResourceCollection;


class GoodsTopResource extends ResourceCollection
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {

        return $this->collection->map(function (GoodsCate $item) {
            return [
                'id' => $item->id,
                'icon' => $item->icon,
                'name' => $item->name
            ];
        });
    }
}
